﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OPMS_V1.BOL;

namespace OPMS_V1.Restricted.Admin
{
    public partial class PropertyAds : System.Web.UI.Page
    {
        ManageProperties manage = new ManageProperties();

        protected void Page_Load(object sender, EventArgs e)
        {
            Session["statusPage"] = "buy";
            //Collecting all the information into one datatable

            //This section is used for displaying the "completed" property ads to the Grid View
            #region This part will result in all the completed property Ads of the particular User

            //Binding the grid view with the records present in datatable
            grdPropertyList.DataSource = manage.ListCompletedPropertyList();
            grdPropertyList.DataBind();

            #endregion This part will show all the completed property ads of the particular User

            //This section is for displaying the incompleted property ads to the Grid View
            #region This part will show all the "incompleted" property ads of the particular User

            //Binding the grid view with the records present in datatable
            grdIncomplete.DataSource = manage.ListIncompletedProperties();
            grdIncomplete.DataBind();

            #endregion This part will show all the "incompleted" property ads of the particular User

        }

        /// <summary>
        /// This function is used for Page index change of Grid View to see multiple records
        /// It is executed when the User requests for Page Index change (Completed List)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grdPropertyList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //Getting the new Page for the Grid View
            grdPropertyList.PageIndex = e.NewPageIndex;
            //Get the data from GetDataSource
            grdPropertyList.DataSource = manage.ListCompletedPropertyList();
            //and bind it to the Grid View
            grdPropertyList.DataBind();
        }

        /// <summary>
        /// This function is used for Page index change of Grid View to see multiple records
        /// It is executed when the User requests for Page Index change (Incomplete List)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grdIncomplete_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //Getting the new Page for the Grid View
            grdIncomplete.PageIndex = e.NewPageIndex;
            //Get the data from GetDataSource
            grdIncomplete.DataSource = manage.ListIncompletedProperties();
            //and bind it to the Grid View
            grdIncomplete.DataBind();
        }
    }
}
